package ru.incoremedia.gwttest.core.server.listener;

import java.util.logging.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import ru.incoremedia.gwttest.core.server.context.ApplicationContext;



public class ApplicationContextListener implements ServletContextListener {
    
    private static final Logger logger = Logger.getLogger(ApplicationContextListener.class.getName());

    @Override
    public void contextDestroyed(ServletContextEvent sce) {
        ApplicationContext.getInstance().destroy();
    }

    @Override
    public void contextInitialized(ServletContextEvent sce) {

        try {
            ApplicationContext.getInstance().init(sce.getServletContext().getInitParameter("projectVersion"));
            logger.info("Context is initialized");
        } catch(Exception e) {
            throw new RuntimeException(e);
        }
    }
}